package cn.kgc.util;


import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.HttpStatus;

import javax.servlet.http.HttpServletResponse;

public class ResponseUtil {
    public static void setResponse(HttpServletResponse response, Result<Object> result) {
        response.setStatus(HttpStatus.OK.value());
        response.setContentType("application/json;charset=UTF-8");
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            objectMapper.writeValue(response.getWriter(), result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

